package com.xiaoyu.lanling.feature.chat.model.message

import `in`.srain.cube.request.JsonData
import com.xiaoyu.im.datamodel.AppMessage
import com.xiaoyu.lanling.common.Constant.MessageAttrsKey.GIFT
import com.xiaoyu.lanling.feature.chat.viewholder.ChatViewHolderManager
import com.xiaoyu.lanling.media.image.ImageLoadParam

class ChatMessageReceiveGiftItem(message: AppMessage) : ChatMessageReceiveBaseItem(message) {

    private val giftJsonData: JsonData = attrs.optJson(GIFT)
    val title: String = giftJsonData.optString("messageTitle")
    val content: String = giftJsonData.optString("messageContent")
    val image: String = giftJsonData.optString("icon")
    val billId: String = giftJsonData.optString("billId")
    val imageLoadParam: ImageLoadParam = ImageLoadParam.newBuilder().setSizeInDP(60).setUrl(image).build()
    val rewardInfo = RewardInfo(attrs.optJson("rewardInfo"))

    override val childrenViewType: Int
        get() = ChatViewHolderManager.TYPE_RECEIVE_GIFT
}